#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>
#include <QEventLoop>
#include <QCloseEvent>
#include <QGraphicsScene>
#include <QGraphicsTextItem>
#include <QFileDialog>
#include <QVector>
#include <QMessageBox>
#include <QSplashScreen>
#include <QSysInfo>
#include <vector>

#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/videoio.hpp>

#include "cam_opencv.h"
#include "video_play.h"
#include "FaceDiscern.h"

#define SICHUAN_UNIVERSITY "/opt/gx-edge-ai-demo/logos/sichuan_university.png"
#define SICHUAN_UNIVERSITY_BIG "/opt/gx-edge-ai-demo/logos/SCU_BIG.png"
#define G2L_HW_INFO "Hardware Information\n\nBoard: RZ/G2L gx-qsb-rzg2l\nCPUs: 2x Arm Cortex-A55\nDDR: 2GB"
#define APP_WIDTH 1024
#define APP_HEIGHT 600

class my_opencv;
class videoplay;
class QGraphicsScene;
class FaceDiscern;

using namespace std;
using namespace cv;
using namespace cv::face;

QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACE

enum Input { cameraMode, imageMode, videoMode };

class Widget : public QWidget
{
    Q_OBJECT

public:
    Widget(QWidget *parent = nullptr);
    ~Widget();

public slots:
    void ShowVideo();

signals:
    void sendMatToDraw(const cv::Mat& matToSend);
    void sendMatToDraw_2(const cv::Mat& matToSend);

private slots:
    void drawMatToView(const cv::Mat& matInput);
    void drawMatToView_2(const cv::Mat& matInput);
    void getImageFrame();
    void createVideoWorker();
    void createFaceWorker();
    void Face_Find_Recognize();

    void on_Cam_Open_clicked();
    void on_Cam_Close_clicked();
    void on_Face_Train_Button_clicked();
    void on_ModelUpdateButton_clicked();
    void on_Face_Rec_On_clicked();
    void on_Face_Rec_Close_clicked();

private:
    Ui::Widget *ui;

    QFont font;
    QPixmap image;
    QPixmap image_face;
    QGraphicsScene *scene;
    QGraphicsScene *scene_face;
    QString boardInfo;
    QString cameraLocation;

    my_opencv *cvWorker;
    videoplay *vidWorker;
    FaceDiscern *faceWorker;

    Input inputMode;

    unsigned int iterations;

    QImage matToQImage(const cv::Mat& matToConvert);
};
#endif // WIDGET_H





